package com.chrray.position.mapper.position;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chrray.position.domain.FdJobPostings;
import com.chrray.position.domain.dto.GrabJobsDTO;
import com.chrray.position.domain.dto.JobRelWorkerDTO;
import com.chrray.position.domain.dto.MyPubJobsDTO;
import com.chrray.position.domain.dto.NearbyWorkerDTO;
import com.chrray.position.domain.dto.search.*;
import com.chrray.position.domain.vo.BossInfoDTO;
import com.chrray.position.pojo.vo.web.FdJobPostingsExeVo;
import com.chrray.position.pojo.vo.web.PositionStaticsRightVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 工作岗位表 持久层
 *
 * @author wusiwee
 * @email wusiwee@163.com
 * @since 1.0.1 2024-08-07
 */
@Mapper
public interface FdJobPostingsMapper extends BaseMapper<FdJobPostings> {

    List<GrabJobsDTO> nearbyJobs(IPage<GrabJobsDTO>  page,@Param("query") GrabJobSearch query, @Param("userId") Long userId);

    List<GrabJobsDTO> pageList(IPage<GrabJobsDTO> page, @Param("query") JobPageSearch query, @Param("userId") Long userId);

    void updateUserCurrentLocation(@Param("userId") Long userId,@Param("data") GrabJobSearch data);

    int grabJob(@Param("jobId") Long jobId, @Param("userId") Long userId);

    BossInfoDTO findBossInfo(@Param("jobId")Long jobId);

    List<GrabJobsDTO> myApply(IPage<GrabJobsDTO> page, @Param("query")MyJobSearchSearch query, @Param("userId") Long userId);

    int cancelApply(@Param("jobId") Long jobId, @Param("userId") Long userId);

    int collectJob(@Param("jobId") Long jobId, @Param("userId") Long userId);

    List<GrabJobsDTO> favoritesList(IPage<GrabJobsDTO> page, @Param("query") MyJobSearchSearch search, @Param("userId") Long userId);

    IPage<FdJobPostingsExeVo> pageMyPostingsApplyList(@Param("page") IPage page, @Param("jobName") String jobName, @Param("jobState") Integer jobState, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("userId") Long userId);

    IPage<FdJobPostings> pageMyPostingsFavList(@Param("page") IPage page, @Param("jobName") String jobName, @Param("userId") Long userId);

    List<MyPubJobsDTO> bossMyPublish(IPage<MyPubJobsDTO> page, @Param("query") BossJobPubSearch search, @Param("userId") Long userId);

    String findDistrictName(@Param("districtId") Long districtId);

    List<JobRelWorkerDTO> jobRelWorker(IPage<JobRelWorkerDTO> page, @Param("query")BossJobRelWorkerSearch search);

    int employ(@Param("jobId") Long jobId, @Param("userId") Long userId);

    int complete(@Param("jobId") Long jobId, @Param("userId") Long userId);

    List<NearbyWorkerDTO> nearbyWorkers(IPage<NearbyWorkerDTO> page,@Param("query") GrabJobSearch search, @Param("userId") Long userId);

    List<PositionStaticsRightVo> positionStaticsRight(@Param("startTime") LocalDate startTime, @Param("endTime") LocalDate endTime);

    int cancelCollectJob(@Param("jobId") Long jobId, @Param("userId") Long userId);

    int completeJob(@Param("jobId") Long jobId, @Param("bossId")Long bossId);

    void tryUpdateJobState2Inprogress(@Param("jobId") Long jobId);

    int checkUpdateJobState();

    void comlateJobWorkerRel(@Param("jobId")Long jobId);
}
